package cn.xval.ft.app.gen.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.xval.fc.base.response.WrapResponse;
import cn.xval.ft.app.gen.service.ProductContactService;
import jakarta.annotation.Resource;
import cn.xval.ft.app.gen.params.ProductContactParams;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.validation.annotation.Validated;
import jakarta.validation.constraints.NotNull;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.PostMapping;
import cn.xval.fc.base.exception.BusinessException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;

@Tag(name="ProductContact", description="")
@RequestMapping(path = "/contact")
@RestController
@WrapResponse
public class ProductContactController {
    @Resource
    private ProductContactService productContactService;
    @Operation(summary = "添加品种合约")
    @PostMapping("create")
    public ProductContactParams.ProductContactInfo create(@RequestBody @Validated @NotNull ProductContactParams.ProductContactCreateRequest arg) throws BusinessException {
        return this.productContactService.create(arg);
    }
    @Operation(summary = "删除合约")
    @GetMapping("remove/{id}")
    public void remove(@PathVariable("id") String id) throws BusinessException {
        this.productContactService.remove(id);
    }
    @Operation(summary = "编辑合约")
    @PostMapping("modify")
    public ProductContactParams.ProductContactInfo modify(@RequestBody @Validated @NotNull ProductContactParams.ProductContactModifyRequest arg) throws BusinessException {
        return this.productContactService.modify(arg);
    }
    @Operation(summary = "获取合约列表")
    @GetMapping("query")
    public List<ProductContactParams.ProductContactInfo> list() throws BusinessException {
        return this.productContactService.list();
    }
}

